package com.iamteer.day07;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;

import org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

public class UserLogin {

	public static void main(String[] args) throws Exception  {
		BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("please input username:");
		String name = bReader.readLine();
		System.out.println("please input password:");
		String password = bReader.readLine();
		
		Document doc = new SAXReader().read(new File("./src/user.xml"));
		String xpath = "//user[@name='" + name + "' and @password='" + password + "']";
		Node user = doc.selectSingleNode(xpath);
		if (user != null) {
			System.out.println("welcome...");
		} else {
			System.out.println("Failed...");
		}
	}

}
